package com.changxianggu.cloud.crawler.core.modules.app.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 在线网课
 * </p>
 *
 * @author hanez
 * @since 2021-01-28
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("cxg_online_course")
public class CxgOnlineCourse extends Model<CxgOnlineCourse> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @NotNull(message = "网课ID编辑时不能为空", groups = {UPDATE.class})
    private Integer id;

    @TableField("title")
    @NotBlank(message = "课程标题不能为空", groups = {CREATE.class, UPDATE.class})
    private String title;

    @TableField("cover")
    @NotBlank(message = "封面不能为空", groups = {CREATE.class, UPDATE.class})
    private String cover;

    /**
     * 富文本介绍
     */
    @TableField("brief")
    private String brief;

    /**
     * 纯文字简介
     */
    @TableField("brief_short")
    private String briefShort;

    /**
     * 关键字数组,英文逗号分隔
     */
    @TableField("keyword_arr")
    private String keywordArr;

    @TableField("create_time")
    private LocalDateTime createTime;

    @TableField("update_time")
    private LocalDateTime updateTime;

    /**
     * 出版社或商户id
     */
    @TableField("press_id")
    private Integer pressId;

    /**
     * 创建的用户名
     */
    @TableField("create_user")
    private String createUser;

    /**
     * 定价
     */
    @TableField("price")
    private BigDecimal price;

    /**
     * 状态(1:正常;0:下架;-1:删除;)
     */
    @TableField("status")
    private Integer status;

    /**
     * 购买用户数
     */
    @TableField("apply_num")
    private Integer applyNum;

    /**
     * 浏览量
     */
    @TableField("view_num")
    private Integer viewNum;

    /**
     * 外链课程的外链地址
     */
    @TableField("link_url")
    private String linkUrl;

    /**
     * 是否外链课程(1:是;0:否;)
     */
    @TableField("is_link")
    @NotNull(message = "是否外链课程不能为空", groups = {CREATE.class, UPDATE.class})
    private Integer isLink;



    /**
     * 副标题
     */
    @TableField("status")
    private String sub_title;

    /*************** 瞬时字段 ***************/
    /**
     * 排序
     */
    @TableField(exist = false)
    private String orderBy;
    /**
     * 状态名称
     */
    @TableField(exist = false)
    private String statusName;

    /**
     * 排序
     */
    @TableField(exist = false)
    private String isLinkName;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    public interface UPDATE {
    }

    public interface CREATE {
    }
}
